package org.rule.function;

import cn.hutool.core.util.StrUtil;
import com.googlecode.aviator.runtime.function.AbstractFunction;
import com.googlecode.aviator.runtime.function.FunctionUtils;
import com.googlecode.aviator.runtime.type.AviatorBoolean;
import com.googlecode.aviator.runtime.type.AviatorObject;

import java.util.Map;

public class StrEqualFunction extends AbstractFunction{
    @Override
    public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2) {
        String str1 = FunctionUtils.getStringValue(arg1, env);
        String str2 = FunctionUtils.getStringValue(arg2,env);
        return AviatorBoolean.valueOf(StrUtil.equals(str1, str2));
    }
    @Override
    public String getName() {
        return "str_equal";
    }
}
